Viability Test
Analyze sites before scraping to find the best strategy. Tests each URL with multiple scraping modes and reports what works.
Basic usage
test = client.create_viability_test(
["https://example.com", "https://hard-site.com"],
depth="full",
)
import time
while True:
result = client.get_viability_test(test.run_id)
if result.status == "completed":
break
time.sleep(2)
for r in result.results:
print(f"{r.url}: {r.recommended_strategy}")
print(f" Difficulty: {r.difficulty}")
print(f" Best mode: {r.best_mode}")
print(f" Browser needed: {r.javascript_required}")
Depth levels
Control how many modes are tested:
| Depth | Modes tested | Credits per URL |
|---|---|---|
"quick" | Simple HTTP only | ~1 |
"standard" | Simple + proxy + browser | up to 7 |
"full" (default) | All modes including browser+proxy | up to 12 |
# Quick check — just test simple HTTP
test = client.create_viability_test(urls, depth="quick")
# Full analysis — test every mode
test = client.create_viability_test(urls, depth="full")
Per-mode results
The modes_tested dict shows results for each scraping mode:
for r in result.results:
if r.modes_tested:
for mode, data in r.modes_tested.items():
status = "OK" if data.success else "BLOCKED"
print(f" {mode}: {status} ({data.time_ms}ms, {data.credits} credits)")
if data.captcha_type:
print(f" CAPTCHA: {data.captcha_type}")
Key result fields
| Field | Description |
|---|---|
difficulty | "easy", "medium", or "hard" |
best_mode | Cheapest mode that worked (e.g. "simple", "browser_proxy") |
recommended_strategy | Suggested scraping approach |
suggested_params | Dict of params to use with client.scrape() |
modes_tested | Dict of mode name to ViabilityModeResult |
total_credits_used | Credits consumed across all mode tests |
captcha_detected | Whether CAPTCHA was found |
captcha_providers | List of protection providers |
javascript_required | Whether browser rendering is needed |
cloudflare_level | Cloudflare protection level |